package day03;


import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

/**
 * park 和 unpark解决先打印2再打印1
 */
@Slf4j
public class test7 {
    public static void main(String[] args) {

        Thread t1 = new Thread("t1") {
            @Override
            public void run() {
                LockSupport.park();
                log.debug("1");
            }
        };

        Thread t2 = new Thread("t2") {
            @Override
            public void run() {
                log.debug("2");
                LockSupport.unpark(t1);
            }
        };

        t1.start();
        t2.start();
    }
}
